(*
**
** An interface for ATS to interact with gsl/gsl_statistics
**
** Contributed by William Blair (wdblair AT cs DOT bu DOT edu)
** Contributed/Reviewed  by Hongwei Xi (hwxi AT cs DOT bu DOT edu)
**
** Starting time: October, 2011
**
*)

(* ****** ****** *)
//
// License: LGPL 3.0 (available at http://www.gnu.org/licenses/lgpl.txt)
//
(* ****** ****** *)

#define ATS_STALOADFLAG 0 // no need fro staloading at run-time

(* ****** ****** *)

%{#
#include "contrib/gsl/CATS/gsl_statistics.cats"
%} // end of [%{#]

staload "prelude/SATS/array.sats"

(* ****** ****** *)

fun gsl_stats_mean
  {a:t@ype}
  {n:int} {s,n1:pos | s*n1 <= n} {l:addr} (
  data: &(@[a][n]),stride: int s, n: size_t n1
) :<> double = "mac#atsctrb_gsl_stats_mean"
// end of [gsl_stats_mean]

fun gsl_stats_variance
  {a:t@ype}
  {n:int} {s,n1:pos | s*n1 <= n}{l:addr} (
  data: &(@[a][n]), stride: int s, n: size_t n1
) :<> double = "mac#atsctrb_gsl_stats_variance"
// end of [gsl_stats_variance]

fun gsl_stats_sd
  {a:t@ype}
  {n:int} {s,n1:pos | s*n1 <= n}{l:addr} (
  data: &(@[a][n]),stride: int s, n: size_t n1
) :<> double = "mac#atsctrb_gsl_stats_sd"
// end of [gsl_stats_sd]


fun gsl_stats_absdev
  {a:t@ype}
  {n:int} {s,n1:pos | s*n1 <= n} {l:addr} (
  data: &(@[a][n]),stride: int s, n: size_t n1
) :<> double = "mac#atsctrb_gsl_stats_absdev"
// end of [gsl_stats_absdev]


fun gsl_stats_skew
  {a:t@ype}
  {n:int} {s,n1:pos | s*n1 <= n} {l:addr} (
  data: &(@[a][n]),stride: int s, n: size_t n1
) :<> double = "mac#atsctrb_gsl_stats_skew"
// end of [gsl_stats_skew]

fun gsl_stats_kurtosis
  {a:t@ype}
  {n:int} {s,n1:pos | s*n1 <= n}{l:addr} (
  data: &(@[a][n]),stride: int s, n: size_t n1
) :<> double = "mac#atsctrb_gsl_stats_kurtosis"
// end of [gsl_stats_kurtosis]

fun gsl_stats_lag1_autocorrelation
  {a:t@ype}
  {n:int} {s,n1:pos | s*n1 <= n}{l:addr} (
  data: &(@[a][n]),stride: int s, n: size_t n1
) :<> double = "mac#atsctrb_gsl_stats_lag1_autocorrelation"
// end of [gsl_stats_lag1_autocorrelation]

(* ****** ****** *)

(* end of [gsl_statistics.sats] *)
